<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="uct" uri="/WEB-INF/uct.tld" %>
<%@ taglib prefix="portal" uri="/WEB-INF/portal.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<%@ include file="/common/sale/include/common-base.jsp"%>
	<script src="${ctx}/js/jquery-tools.min.js"></script>
  <script src="/common/sale/bootstrap-menu/BootstrapMenu.min.js"></script>
  
  <title>委托撤单查询</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>
<body class="hold-transition ${sysUserColor} sidebar-mini">
<div class="wrapper">
  <!-- top start -->
  <%@include file="/common/sale/top-user.jsp" %>
  <!-- top end -->
<!-- left start -->
  <%@include file="/common/sale/left-user.jsp" %>
<!-- left end-->
 <!-- main start -->
  <div class="content-wrapper">
	  <div class="content">
		  <div class="row">
			  <div class="col-lg-12 rightmt">
	           <div class="right_box">
	               <!-- 我的历史申购搜索 开始-->
			            <form id="searchForm" class="form-horizontal">
						<input type="hidden" name="pageName" value="trsOrder-list"/>
						<input type="hidden" name="formName" value="searchForm">
						<input type="hidden" name="trsOrder.w_delStatus" value="F">
				    	<input type="hidden" name="orderBy" value="trsOrder.create_time desc" />
				    	<input type="hidden" name="trsOrder.w_userOwner"  value="${loginUser.userEname}" /> 
				    	<input type="hidden" name="trsOrder.wi_isDeal"  value="F,T0" />
				    	<input type="hidden" name="trsOrder.w_isKill"  value="F" />
				    	<input type="hidden" name="trsOrder.w_orderDate"  value="" />
				    	
				         <!-- 我的挂牌搜索 start -->
						 <h4 class="user_title">
						   <p><i class="fa fa-search"></i><span>委托撤单搜索</span></p>
						 </h4>
					    <!-- 我的挂牌搜索 end -->   
					    
			            	<div class="box-body">  
			            	<div class="form-group">
			            	
								<label  class="col-sm-3 control-label">
									商品代码：
								</label>
								<div class="col-sm-2">
									<input type="text" class="form-control"  name="trsOrder.wl_proNo" id="proNo" value="" />
								</div>
								<label  class="col-sm-3 control-label">
									商品名称：
								</label>
								<div class="col-sm-2">
									<input type="text" class="form-control"  name="trsOrder.wl_proName" id="proName" value="" />
								</div>
							</div>
							<div class="form-group">
								<label  class="col-sm-3 control-label">
									买卖方向：
								</label>
								<div class="col-sm-2" style="padding-top:6px;">
									<select class="form-control" name="trsOrder.w_orderFlag" id="orderFlag">
										<option value="">--请选择--</option>
										<option value="sell">卖</option>
										<option value="buy">买</option>
										
									</select>
						    	</div>
							</div>
						</div>
			            <center>
				            <div class="box-footer clearfix">
				              <a href="javascript:void(0)" class="btn btn-danger " onclick="getTableData();">查询</a>
				              <a href="javascript:void(0)" class="btn btn-primary" onclick="FormUtil.cleanData('searchForm');">重置</a>
				            </div>
			            </center>
			         </form>
			        </div>
			       <!-- 我的挂牌搜索 结束-->
			       
			       <div class="right_box" style="margin-top:20px;">
				         <!-- 我的挂牌搜索 start -->
								 <h4 class="user_title">
								   <p><i class="fa fa-line-chart"></i><span>委托撤单查询</span><span style="color: red">【提示：右键每条数据，可以进行撤单操作】</span></p>
								 </h4>
					    <!-- 我的挂牌搜索 end -->   
			            <table id="example" class="table table-hover user_table" >
			                <thead>
			                <tr>
		                         <th>序号</th>
		                         <th>商品代码</th>
		                         <th>商品名称</th>
		                         <th>委托编号</th> 
		                         <th>委托时间</th>
		                         <th>委托价格（元）</th>
		                         <th>委托数量</th>
		                         <th>买卖方向</th>
		                         <th>成交状态 </th>
		                         <th>成交数量</th>
		                  		<!-- <th>操作</th> -->
			                </tr>
			                </thead>
			                <tbody id="myList">
			                </tbody>
			              </table>
		         	    <center>
		    	  			  <ul id="pageList"></ul>
		        		</center>
			        </div>
			     
			       <!-- 我的挂牌搜索 结束-->
	       
	        </div>
	       <!-- right end -->
	      </div>
	      </div>
	      </div>
	 <!-- mainrow end -->
</div>
 <!-- main end -->     
    
   <!-- foot start -->
 <%@include file="/common/sale/foot-user.jsp" %>
 <!-- foot start -->   



<div win-title="查看窗口" class="modal fade" id="my_modal_view" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:900px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">查看详情</font> 
						</h4>
					</div>
					<div class="modal-body">
						<div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="viewmyTab">
					            </ul>
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					            
					                  
					               <div class="tab-pane active" id="view_tab_1">
					                  <form class="form-horizontal" role="form" id="viewForm1" action="javascript:void(0)">
							                <!--trsBuy start-->
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">交易商名称</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.userRealName"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">申购数量</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.num"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">中签数量</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.numReal"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">申购价格</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.price"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">手续费比例</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.commScale"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">状态</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.buyStatus"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">付款状态</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.payStatus"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">付款类型</label>
												<div class="col-sm-8">
						                			<span data-name="trsBuy.payStyle" data-url=""></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">电话号码</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.tel"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">认购类型</label>
												<div class="col-sm-8">
						                			<span data-name="trsBuy.rengouType" data-url="doCode=dictItemList&cateEname=rengouType"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">认购时间</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.rengouTime"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">商品代码</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.proNo"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">成交总价</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.totalPrice"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">交易商账号</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.userName"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">最大申购数量</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.maxNum"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-5">
												<label  class="col-sm-4 control-label">最小申购数量</label>
												<div class="col-sm-8">
													<span data-name="trsBuy.minNum"></span>
												</div>
											</div>
											
								        	<!--trsBuy end-->
					                    
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
									         	<button class="btn btn-danger" type="button" style="width: 200px;" onclick="cannel('view');"> 关闭 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
					          
				            </div>
					            <!-- tab content e -->
				          </div>	
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>

</body>
	<script type="text/template" id="dataList">
	  	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr class="tableRow" data-row-id="<?=i?>">
			<td class="text_c"><?=(pageObj.currentPage-1)*10+(i+1) ?></td>
			<td class="text_c"><?=strUtil.subStr(rows[i].proNo,7)?></td>
			<td class="text_l"><?=strUtil.subStr(rows[i].proName,7)?></td>
			<td class="text_c"><?=strUtil.doNull(rows[i].orderNo,'')?></td>
			<td class="text_c"><?=strUtil.doNull(rows[i].createTime,'')?></td>
			<td class="text_r">￥<?=strUtil.doNull(rows[i].orderPrice,'')?></td>
            <td class="text_r"><?=strUtil.doNull(rows[i].orderNum,'')?></td>
			<td class="text_c">
					<? if('sell' == rows[i].orderFlag){ ?>卖出
					<? } else if ('buy' == rows[i].orderFlag){?>买入
					<? } ?>
			</td>
			<td class="text_c">
					<? if('F' == rows[i].isDeal){ ?>未成交
					<? } else if ('T' == rows[i].isDeal){?>全部成交
					<? } else if ('T0' == rows[i].isDeal){?>部分成交
					<? } ?>
            </td>
			<td class="text_r"><?=strUtil.doNull(rows[i].dealNum,'-')?></td>

            <td style="display:none"><?=rows[i].proId?></td>
             <!--暂时注释掉
				<td class="text_c">
					<button type="button" class="btn btn-success btn-xs" onclick="toLoad1('<?=rows[i].buyId?>','view')">查看</button>  
				</td>
			-->
		</tr>
   <?}?> 
	</script>
	
<script>
var clickMenu= "order-list-kill";
var id,myPage,dataListId,searchFormId,isShowLog,tableSort,tableId;
myPage = 10;
dataListId = "dataList";
searchFormId = "searchForm";
tableSort = "trsOrder";
tableId = "orderId";
isShowLog = true;
var paramData = {};
$(function () {
	getTableData();

});



//清空数据
function cleanData(id){
	$('#'+id).find(".clean").val("");//按照样式清空；
}

function getTableData(){
	deleteAllRow('example');
	//搜索去除空格
	$("#proNo").val($("#proNo").val().trim());
	$("#proName").val($("#proName").val().trim());
	var nowDate = new Date().format("yyyy-MM-dd");
	
	$("#searchForm").find("input[name='trsOrder.w_orderDate']").val(nowDate);
	$.ajax({
		   type:'get',
		   url:common_list_url,
		   data:$('#searchForm').serialize()+getCurrentPage(common_list_url+"?"+$('#searchForm').serialize(),myPage),
		   async:false,
		   dataType:'json',
		   success: function(myData){
			var data = baidu.template('dataList',eval(myData));  
			var menu = new BootstrapMenu('.tableRow', {
				fetchElementData: function($rowElem) {
				    var rowId = $rowElem.data('rowId');
				    return myData.rows[rowId];
				  },
				  actions: [{
				      name: '撤单',
				      onClick: function(row) {
				    		var index_submit = layer.confirm('您确定要撤销委托编号【'+row.orderNo+'】的挂单吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
				    		, function(){
				    			layer.close(index_submit);
				    			var paramLoadData = {"trsOrder.orderId":row.orderId,"trsOrder.proId":row.proId,"pageName":"trs-order-cancel","formName":"cancelForm"};
				    			$.ajax({url: common_submit_url,type: "post",dataType: "json" ,data:paramLoadData,
				    		      success: function(data){
                                      	console.log(data);
										if(data){
											layer.alert(data.msg);
											refresh();
										}
				    		        }
				    		    });
				    		});
				      }
				  }]
				});
			
			
			$("#myList").html(data);
			  var option= {
					   ele:$("#pageList")[0],
					   total:myData.total,
					   fn:getTableData,
					   url:common_list_url+"?"+$('#searchForm').serialize()
				   }
			generatePages(option);
		   }
		});	
  }

function deleteAllRow(tableId){
	var tb = document.getElementById(tableId);
	if(tb){
	     var rowNum=tb.rows.length;
	     for (var i=1;i<rowNum;i++){
	         tb.deleteRow(i);
	         rowNum=rowNum-1;
	         i=i-1;
	     }
     }
}

function setToken(){
	$.ajax({
	    type:'get',
	    url:'${ctx}/sendPage/token?token=true',
	    dataType:'text',
	    success: function(myData){
	    	paramData.formToken = myData;
	  	}
	});	
}

function cannel(modalId){
	$('#'+modalId).modal('hide');
}

function refresh(){
    //window.location.reload();
	getTableData();
}




 
//回车查询
document.onkeydown=function mykeyDown(e){  
      //compatible IE and firefox because there is not event in firefox  
       e = e||event;  
       if(e.keyCode == 13) {getTableData();}   
       return;  
};



//  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

//查看，修改，删除  
//读取（查询、编辑）数据
function toLoad(id,type){
	
	var paramLoadData = {"oaLoanBill.w_infoId":id,"modelTypes":"s_"+tableSort};
	loadObj(type,paramLoadData);
}



//toLoad1 读取（查询、编辑）数据
function toLoad1(id,type){
	var paramLoadData = {"formName":"searchForm","pageName":"history-list.jsp","trsOrder.w_orderId":id};
	showModal(type);
	$.ajax({
	    type:'get',
	   	url:common_info_url+"?doCode=dymicSql",
	    data: paramLoadData,
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	console.log(myData);
	    	
			//FormUtil.loadView("trsBuy", myData.trsBuy);
			FormUtil.loadView("trsOrder", myData);
			//DictUtil.getCommonDictData("select","#editForm_trsOrder_isDeal","trsOrder.isDeal","doCode=dictItemList&cateEname=isDeal","",myData.isDeal);
			 
	  	}
	});
}

function toDele(id){
	var index_submit = layer.confirm('您确定要删除信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var paramLoadData = {"modelTypes":"d_trsOrder","trsOrder.w_orderId":id};
		//var paramLoadData = {"modelTypes":"u_trsBuy","trsBuy.delStatus":"T","trsBuy.w_buyId":id};
		doDele(paramLoadData);
	});
}

//弹框
function showModal(type){
	if("view"==type){
		$("#my_modal_view").modal("show");
	}else if("edit"==type){
		//修改弹框时，初始化数据字典
		cleanData('editForm');
		DictUtil.getCommonDictData("select","#editForm_trsBuy_rengouType","trsBuy.rengouType","doCode=dictItemList&cateEname=rengouType","","");
		$("#my_modal_edit").modal("show");
	}
}


function submitForm1(formId,tabId){
	var result = submitForm(formId,tabId);
	if(result){
		if(result.flag=='T'){
    		var num = formId.slice(-1);
    		if(num!=null &&　num !=""){
    			num=parseInt(num)+1;
    			defaultTab = "#tab_"+num;
    		}
      		layer.alert('操作成功！', {closeBtn: 0 });
      		refresh();
      		cannel('');
      		cannel('edit');
	     }
	}
 }
function submitForm(formId,tabId){
	var result;
	if(tabId!=null && tabId!="" && tabId!="undefined"){
	}else{
		var proName = $("#"+formId+"_proName").val();
	}
	var index_load = layer.load(1, {shade: false});
	$.ajax({
	    type:'post',
	    url:common_submit_url,
	    data:$("#"+formId).serialize(),
	    async:false,
	    dataType:'json',
	    success: function(myData){ 
	     console.log(myData);
	        if(myData.flag=="T"){
	        result = myData;
	        if(myData.ids){
	        	
	        }
	    	}else{
	    		setToken();
	     		layer.alert(myData.msg, {
	    		    closeBtn: 0
	    		  });
	    	}
	        layer.close(index_load);

	  	},
	     error: function (e) {
		     layer.close(index_load);
     	} 
	});	
	return result;
}
var dateObject = $('#datepicker').datepicker( {
	language : 'zh-CN',
	//inline: true,
	todayBtn : "linked",
	format : "yyyy-mm-dd",
    autoclose: true
});
var dateObject = $('#datepicker1').datepicker( {
	language : 'zh-CN',
	//inline: true,
	todayBtn : "linked",
	format : "yyyy-mm-dd",
    autoclose: true
});

</script>
</html>
